Arch Linux Notes
Table of Contents
- Resources
- Setup install USB Drive
- Connect to Internet
- Time
- Disks
- Pacstrap
- Generate fstab
- Chroot
- Timezone
- Locale
- Networking
- Initramfs
- Password
- Microcode
- Boot Manager
- Enabling Services
- Rebooting
- Join wifi
- User accounts
- Caps Lock Control
- Basic Packages
- Serial Communication
- X Windows
- Sound
- Laptop Media Keys
- Populate and refresh pacman keys
- Printing
- OpenTTD and MIDI
- Building Emacs
- XFCE4
- miniflux
Resources
Setup install USB Drive
- Obtain the latest archlinux iso and verify it downloaded correctly
- Use dd to write the image to the removable drive
dd bs=4M if=path/to/archlinux-version-x86_64.iso of=/dev/<YOUR_USB_DRIVE> conv=fsync oflag=direct status=progress
Connect to Internet
WiFi
- Use
iwctl
to connect to a wifi network - Type
help
to see various examples of how to use iwctl station wlan0 connect <NAME_OF_NETWORK>
- Enter the password at the prompt
- If it connected you can exit iwctl
Time
- Set the clock to use ntp
timedatectl set-ntp true
Disks
Partitioning
TODO MBR
UEFI
- Verify you booted in UEFI mode
ls /sys/firmware/efi/efivars
- If you are able to run the above without errors then you are in uefi mode
- Use
lsblk
to view the detected harddrives - Parition the main drive with
gdisk /dev/<YOUR_MAIN_DRIVE>
- Delete any existing paritions
- Create a 512MB partition with code EF00
- Create a parition with the remaining space with code 8300
- Write the changes to disk
Formatting
Full Disk Encryption
- Run
lsblk
again to see the new partition numbers - Run cryptsetup on the main linux parition
cryptsetup luksFormat /dev/<MAIN_DRIVE_LINUX>
- Open the encrypted partition as cryptroot
cryptsetup open /dev/<MAIN_DRIVE_LINUX> cryptroot
- Format cryptroot with ext4
mkfs.ext4 /dev/mapper/cryptroot
- Mount cryptroot to /mnt
mount /dev/mapper/cryptroot /mnt
TODO Unencrypted
EFI System Partition
- Run
mkfs.fat -F32 /dev/<MAIN_DRIVE_EFI>
- Make mount point
mkdir /mnt/boot
- Mount the efi partition
mount /dev/<MAIN_DRIVE_EFI> /mnt/boot
Pacstrap
- Use pacstrap to download initial packages
pacstrap /mnt base base-devel linux linux-firmware dhcpcd iwd mg mailutils
Generate fstab
- Use genfstab to generate an fstab
genfstab -U /mnt >> /mnt/etc/fstab
Chroot
- Use the arch-chroot command to chroot into the new partition
arch-chroot /mnt
Timezone
- Symlink your timezone to /etc/localtime
ln -sf /usr/share/zoneinfo/America/Kentucky/Louisville /etc/localtime
Locale
- Edit /etc/locale.gen and uncomment your locale
- For example
mg /etc/locale.gen
and uncomenten_US.UTF-8 UTF-8
- Generate locale
locale-gen
- Set the locale
localectl set-locale LANG=en_US.UTF-8
- Create a file
/etc/locale.conf
and set the contents toLANG=en_US.UTF-8
Networking
- Create the hostname file with your hostname
/etc/hostname
- Edit the
/etc/hosts
to like below
127.0.0.1 localhost ::1 localhost
Initramfs
- If you are using full disk encryption you need to update the initramfs
- Edit
/etc/mkinitcpio.conf
- Edit the hooks to be like this
HOOKS=(base udev autodetect modconf block keyboard encrypt filesystems fsck)
- Run
mkinitcpio -P
to generate the image
Password
- Run
passwd
to set the root password
Microcode
- Install either
pacman -Sy intel-ucode
orpacman -Sy amd-ucode
if that applies
Boot Manager
- Run
bootctl install
to install the systemd boot manager - Create a boot loader entry in
/boot/loader/entries/arch.conf
with the below text - You can get the partition UUID (not PARTUUID) from
blkid
and make sure you set the ucode to match your CPU type - Ensure that it is the partition UUID and not the
/dev/mapper/cryptroot
one
title Arch Linux linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options cryptdevice=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:cryptroot root=/dev/mapper/cryptroot rw
- Edit the
/boot/loader/loader.conf
to use your new config
default arch.conf timeout 5 console-mode max editor no
- You can see if it worked by running
bootctl list
Enabling Services
- Enable iwd wifi service
systemctl enable iwd
- Enable dhcpcd service
systemctl enable dhcpcd
Rebooting
- Exit the chroot environment
- Unmount the
/mnt/boot
partition and the/mnt
partition - Run
reboot
and test out the new install - Ensure that the computer doesn't try to boot the usb stick again
Join wifi
- If you need to join wifi you should be able to use
iwctl
to communicate withiwd
- From there it should be same as before
- For example,
station wlan0 connect <NAME_OF_NETWORK>
Wifi interface is not visible?
- If you are unable to see the wifi interface after rebooting try restarting the
iwd
service
User accounts
- You should create a user outside of the root user on the machine
- Run
useradd -m -G wheel,uucp <USER_NAME>
to create a new user - Run
passwd <USER_NAME>
to set that new user's password - Install sudo if you haven't already
pacman -Sy sudo
- Set the EDITOR environment variable and run visudo
export EDITOR=mg && visudo
- From here uncomment the line that mentions the wheel group
- After this you should be able to log in as the newly created user and run sudo commands
Caps Lock Control
- Make the directory for keymaps
sudo mkdir -p /usr/local/share/kbd/keymaps
- Create a file named
/usr/local/share/kbd/keymaps/personal.map
(you might need to create any missing directories) - Give it the contents below
keymaps 0-127 keycode 58 = Control
- Edit
/etc/vconsole.conf
and set its contents to the followingKEYMAP=/usr/local/share/kbd/keymaps/personal.map
- After the next reboot the caps lock key should be an extra control inside the console
Basic Packages
pacman -Sy emacs man man-pages tmux ncdu fzf mosh rsync pass pass-otp curl wget gnupg git cronie cdparanoia abcde beets python-pip ctags aspell aspell-en htop unzip zip pv nethack sshfs p7zip zbar ledger
- Don't forget to enable cronie
systemctl enable cronie.service
Serial Communication
- Install picocom
sudo pacman -Sy picocom
- Plug in you USB serial device and try it out
- For example,
picocom -b 115200 /dev/ttyUSB0
- To find the serial device you can run dmesg and grep the output for tty
sudo dmesg | grep tty
- I do not recommend running picocom inside eshell, ansi-term is a better choice
- Use
C-a C-x
to exit picocom when you are done, if inside of emacs you might need to typeC-x
twice - If you have issues with permissions ensure your user is in the
uucp
group with the commandgroups
X Windows
- Install xorg with
sudo pacman -Sy xorg-server xorg-apps xorg-xinit
- Install the right graphics driver
sudo pacman -Sy xf86-video-{amdgpu, ati, intel, nouveau}
- Proprietary nvidia drivers are installed with
sudo pacman -Sy nvidia
- Based on you graphics driver you might also need to install mesa
sudo pacman -Sy mesa
- Install git
sudo pacman -Sy git
- Clone dwm
mkdir ~/src && cd ~/src && git clone https://git.suckless.org/dwm
- Build and install dwm
cd ~/src/dwm && sudo make install
- Clone dmenu
cd ~/src && git clone https://git.suckless.org/dmenu
- Build and install dmenu
cd ~/src/dmenu && sudo make install
- Clone slstatus
cd ~/src && git clone https://git.suckless.org/slstatus
- Build and install slstatus
cd ~/src/slstatus && sudo make install
- Create an .xinitrc in your homedir and set dwm and start dwm in it
- Test out x by running
startx
from the terminal - Install lightdm and the gtk greeter
sudo pacman -Sy lightdm lightdm-gtk-greeter
- Edit the
/etc/lightdm/lightdm.conf
and uncomment greeter-session and set it tolightdm-gtk-greeter
- Enable lightdm
sudo systemctl enable lightdm
- Create
/usr/share/xsessions/dwm.desktop
and use the below code
[Desktop Entry] Name=dwm Comment=Login using dwm Exec=/usr/local/bin/dwm TryExec=/usr/local/bin/dwm Type=Application
Packages
sudo pacman -Sy xterm firefox arandr pavucontrol xlockmore xss-lock ttf-hack noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra terminus-font xorg-xbacklight pamixer mpv redshift thunar zathura zathura-pdf-mupdf zathura-cb xorg-fonts xorg-fonts-100dpi xorg-fonts-75dpi xorg-fonts-misc xorg-fonts-type1 xorg-fonts-cyrillic vlc kitty imagemagick feh mupdf mupdf-tools libmupdf ghostscript texlive-most
- Start lightdm to confirm its working
sudo systemctl start lightdm
Sound
- Install
pipewire pipewire-docs pipewire-pulse
- You might need to restart for the the service to be started properly
Bluetooth Audio
- Install
bluez bluez-utils
- Enable bluetooth service
bluetooth.service
- Run
bluetoothctl
and follow the below example
power on agent on default-agent scan on # Find the address of the device you want to connect to # Ensure the device you want to connect to is in pairing mode pair <ADDRESS> connect <ADDRESS> trust <ADDRESS> # this is for auto connecting scan off exit
- After a reboot you might need to manually power on bluetooth and set the agent
power on agent on default-agent
Laptop Media Keys
- Install dunst for desktop notifications
sudo pacman -Sy libnotify dunst
- There are various util commands that make it easy to bind to keys in dwm in the utils.org
Populate and refresh pacman keys
- Sometimes package signatures are out of date
- To update them run
sudo pacman-key --populate
andsudo pacman-key --refresh-keys
- You might also need to reinstall the key ring,
sudo pacman -S archlinux-keyring
Printing
- ArchWiki
- Install
cups
- Enable cups
sudo systemctl enable --now cups
- For network printing install
nss-mdns
andavahi
and enabled avahisudo systemct enable --now avahi-daemon
- Add
mdns_minimal [NOTFOUND=return]
to the file/etc/nsswitch.conf
after themymachines
and beforeresolve
anddns
- Use
lpinfo -v
to see a list of printer URIs - Use
lpadmin
to add a printer queue, for examplelpadmin -p <PRINTER_QUEUE_NAME> -E -v "ipp://URL" -m everywhere
- Use
lpoptions -d <PRINTER_QUEUE_NAME>
to make the printer default - Enable the printer with
cupsenable <PRINT_QUEUE_NAME>
- Set the printer to accept jobs
cupsaccept <PRINT_QUEUE_NAME>
- To print a test page use
lpr /usr/share/cups/data/testprint
- To print a file use
lpr <SOME_FILE>
orlpr -# <NUMBER_OF_COPIES> <SOME_FILE>
- cups has a web UI acceptable here http://localhost:631/
OpenTTD and MIDI
- Install OpenTTD packages:
openttd
,openttd-opensfx
,openttd-opengfx
- In order to hear music you need to download some music from the online updater in the game
- Install the
soundfont-fluid
in order to hear the music from the game
Building Emacs
- clone emacs from savannah
git clone -b master git://git.sv.gnu.org/emacs.git
- Releases are usually in a branch with the version number, for example
emacs-28
- Run the
./autogen.sh
to build the configure script - Use this command to configure with native compilation
./configure --with-native-compilation
- On Arch Linux you might need to grab
libgccjit
from AURmkdir ~/aur && git clone https://aur.archlinux.org/libgccjit.git && cd ~/aur/libgccjit && makepkg -si
- This will warn you about any missing dependencies, from there you should obtain them for your OS
- Build emacs with
make -j <NUMBER_OF_CPU_CORES+1>
- Run
make install
with appropriate permissions to install the new version on the system - Use
M-x emacs-version RET
to see the current version info, including the build date
XFCE4
- ArchWiki: XFCE4
- Install
xfce4
andxfce4-goodies
miniflux
Install
PostgreSQL
- miniflux requires PostgreSQL,
sudo pacman -Sy postgresql
- Become the
postgres
usersudo -iu postgres
- Initialize the DB as the
postgres
user,initdb -D /var/lib/postgres/data
- Return to the normal user with
exit
- Enable and start the PostgreSQL systemd service,
sudo systemctl enable --now postgresql.service
- Verify it is running with
systemctl status postgresql
- Become the
postgres
user again,sudo -iu postgres
- Create the miniflux user,
createuser -P miniflux
(you will need to set the password) - Create the miniflux2 database owned by the miniflux user,
createdb -O miniflux miniflux2
- Enabled the
HSTORE
extension theminiflux2
db,psql miniflux2 -c 'create extension hstore'
miniflux
- There is a community package in arch for miniflux called
miniflux
- Become the
postgres
user,sudo -iu postgres
and runpsql
- Alter the
miniflux
user temporarily to haveSUPERUSER
priviledges to run the migration,ALTER USER miniflux WITH SUPERUSER;
- Type
exit
to leavepsql
then become the normal user withexit
- Run
miniflux -migrate
to prepare the database - Become the
postgres
user again and remove theSUPERUSER
permissions on theminiflux
user,ALTER USER miniflux with NOSUPERUSER;
- Become the normal user again and create the admin account,
miniflux -create-admin
- Enable and start the miniflux systemd service,
sudo systemctl enable --now miniflux.service
- You can set the port in
/etc/miniflux.conf
,PORT=8081
or whatever you want - You might want to adjust the polling frequency to be faster than 60 minutes,
POLLING_FREQUENCY=15